﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataLoad.iContact.WinClient
{
    public partial class frmEditName : Form
    {
        public frmEditName()
        {
            InitializeComponent();
            _organisations = new List<string>();
        }

        private string _name;

        public string ContactName
        {
            get
            {
                return _name;
            }
        }

        private List<string> _organisations;

        public List<string> Organisations
        {
            get
            {
                return _organisations;
            }
        }

        public DialogResult Show(string defaultName, List<string> defaultOrganisations)
        {
            edtName.Text = defaultName;

            if (defaultOrganisations.Count > 0)
            {
                edtOrganisation.Lines = defaultOrganisations.ToArray();
            }
            else
            {
                edtOrganisation.Text = string.Empty;
            }

            if (ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(edtOrganisation.Text.Trim()))
                {
                    _organisations = new List<string>(edtOrganisation.Lines);
                }

                _name = edtName.Text;

                return DialogResult.OK;
            }
            else
            {
                return DialogResult.Cancel;
            }
        }
    }
}
